<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<p>
		
		<span></span>年

	</p>
	<p>
		<span></span>月

	</p>
	<p>
		
		<span></span>日

	</p>
	<p>
	
		<span></span>时

	</p>
	<p>

		<span></span>分

	</p>
	<p>
		
		<span></span>秒

	</p>
	<script type="text/javascript">
		let span = document.querySelectorAll("p span")
		
		function time(){
			// 获取当前时间 返回中国标准时间
		let date = new Date()
		console.log(date)

		let year = date.getFullYear()//2025 获取年份
		let month = date.getMonth() + 1 //返回月份 0-11 需要手动+1
		let day = date.getDate() //16 返回日期 1-31
		let hour = date.getHours()//11 返回0-23小时
		let minute = date.getMinutes()//6  返回0-59分钟
		let second = date.getSeconds()//秒  0-59秒
		let millisecond = date.getMilliseconds()//毫秒 0-999
		console.log(year, month, day, hour, minute, second, millisecond)

		span[0].innerText = year
		span[1].innerText = month
		span[2].innerText = day
		span[3].innerText = hour
		span[4].innerText = minute
		span[5].innerText = second

		}
		time()

		setInterval(time, 1000)
	</script>
</body>
</html>